import Vue from 'vue'
import Vuex from 'vuex'
import { setItem, getItem, removeItem } from '@/utils/storage'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    user: getItem('TOKEN_KEY')
  },
  mutations: {
    saveToken(state, data) {
      state.user = data
      setItem('TOKEN_KEY', data)
    },
    removeToken(state, data) {
      state.user = data
      removeItem('TOKEN_KEY')
    }

  },
  actions: {
  },
  modules: {
  }
})
